<template>
  <li class="course-item" @click="clickCourse">

    <div class="course-item-left">
      <img v-bind:src="item.thumbImgUrl" alt="">
    </div>

    <div class="course-item-right">
      <div>
        <h3 class="course-item-name">{{item.name}}</h3>
        <div class="course-item-brief">{{item.briefDesc}}</div>
      </div>
      <div class="course-item-more">
        <div class="course-item-author">
          <img v-bind:src="item.authorImgUrl" alt="">
          <div class="course-item-author-name">{{item.authorName}}</div>
        </div>
        <div class="course-item-price">
          <span class="course-item-price-org" v-if="item.orgPrice > 0">¥{{item.orgPrice|priceFormat}}</span>
          <span class="course-item-price-disc">¥{{item.discPrice|priceFormat}}</span>
        </div>
      </div>
    </div>

  </li>
</template>

<script>

export default {
  name: 'sq-course-item',
  props: {
    item: {
      type: Object,
      required: true
    }
  },
  methods: {
    clickCourse() {
      this.$emit('clickCourse');
    }
  }
}
</script>

<!-- custom mint-ui -->
<style scoped>

  .course-item {
     width:100%;
     display:flex;
     border-bottom:1px solid #eee;
  }

  .course-item .course-item-left {
    padding: 12px 16px 0px 12px;
    flex-basis: 80px;
    flex: 0 0 auto;
  }
  .course-item .course-item-left img{
    width: 74px;
    height: 74px;
    border: 1px solid #dddddd;
  }

  .course-item .course-item-right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: left;
    padding-right:12px;
    width:100%;
  }

  /* name & brief */
  h3.course-item-name {
    margin: 12px 0px 10px 0px;
    font-size: 18px;
    line-height: 21px;
    color: #000000;
    font-weight: normal;
  }

  .course-item div.course-item-brief {
    font-size: 14px;
    line-height: 16px;
    color:#666;
    margin-bottom: 14px;
  }

  /* author & price */
  .course-item-right .course-item-more{
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    margin-bottom: 12px;
  }

  .course-item-author {
    height:27px;
    display: flex;
    align-items: center;
    flex-basis: 100px;
    min-width: 100px;
  }
  .course-item-author img{
    width: 27px;
    height: 27px;
    border-radius: 13.5px;
  }
  .course-item-author-name{
    font-size:14px;
    padding-left:8px;
    color: #666;
  }

  .course-item-price {
    text-align: right;
  }
  .course-item-price-org {
    text-decoration:line-through;
    color: #666;
  }
  .course-item-price-disc {
    padding-left:5px;
    color: #ff4a3d;
  }

</style>

